package goover.unit03;

import java.util.Iterator;
import java.util.LinkedList;

public class LinkedListDemo01 {
    public static void main(String[] args){
        LinkedList llt = new LinkedList();
        llt.add("stu1");
        llt.addFirst("stu0");
        llt.addLast("stu2");
        Iterator iterator = llt.iterator();
        while (iterator.hasNext()){
            Object obj = iterator.next();
            if("stu0".equals(obj)){
                iterator.remove();
            }
            System.out.println(obj);
        }
        System.out.println("-------------------------------");
        for(Object o : llt){
            System.out.println(o);
        }
        System.out.println(llt.getFirst());
        System.out.println(llt.getLast());
        System.out.println(llt.removeFirst());
        System.out.println(llt.removeLast());
        llt.offer("stu2");
        llt.offerFirst("stu0");
        System.out.println(llt.peek());
        System.out.println(llt.peekFirst());
        System.out.println(llt.peekLast());
        System.out.println(llt.poll());
        System.out.println(llt.pollLast());
        llt.push("stu0");
        System.out.println(llt.pop());
    }
}
